import os

num = '0'

def savetemp(path,content):
    if isinstance(content, dict):
        path = f"results/{num}temp/{path}"
        os.makedirs(os.path.dirname(path), exist_ok=True)
        import json
        with open(path, "a", encoding="utf-8") as file:
            json.dump(content, file, ensure_ascii=False, indent=4)
            file.write("\n")
    elif isinstance(content, list):
        savetemp_one_by_one(path,content)
    else:
        path = f"results/{num}temp/{path}"
        os.makedirs(os.path.dirname(path), exist_ok=True)
        with open(path, 'a', encoding='utf-8') as file:
            file.write(f"{content}\n")
            file.write("\n")

def savetemp_one_by_one(path,content):
        path = f"results/{num}temp/{path}"
        os.makedirs(os.path.dirname(path), exist_ok=True)
        with open (path, 'a', encoding='utf-8') as file:
            for c in content:
                file.write(f"{c}\n")
            file.write("\n")